/**
 * 
 */
package com.sci.web.action.datareportseason.enterprise_labor_capacity;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import com.sci.web.action.util.BaseAction;
import com.sci.web.bean.Enterprise_Labor_Capacity;
import com.sci.web.dao.DataReportM_InnovateBaseDao;

/**
 * @author BaiFuyou
 * @date: Nov 10, 2011 3:40:52 PM
 * 
 * 插入一条新的生产率数据
 */
public class AddNewLabor_capacity_productivityAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3374810276390375971L;
	@Resource
	private DataReportM_InnovateBaseDao dataReportM_InnovateBaseDao;
	private int userId;
	private int labor_capacity_staff_count;
	private int type;
	private String year;
	private double labor_capacity_added_value;
	private double labor_capacity_productivity;

	/**
	 * @return the userId
	 */
	public int getUserId() {
		return userId;
	}

	/**
	 * @param userId
	 *            the userId to set
	 */
	public void setUserId(int userId) {
//		System.out.println(userId+"=userId");
		this.userId = userId;
	}

	/**
	 * @return the labor_capacity_staff_count
	 */
	public int getLabor_capacity_staff_count() {
		return labor_capacity_staff_count;
	}

	/**
	 * @param labor_capacity_staff_count
	 *            the labor_capacity_staff_count to set
	 */
	public void setLabor_capacity_staff_count(int labor_capacity_staff_count) {
//		System.out.println(labor_capacity_staff_count+"=labor_capacity_staff_count");
		this.labor_capacity_staff_count = labor_capacity_staff_count;
	}

	/**
	 * @return the type
	 */
	public int getType() {
		return type;
	}

	/**
	 * @param type
	 *            the type to set
	 */
	public void setType(int type) {
//		System.out.println(type+"=type");
		this.type = type;
	}

	/**
	 * @return the year
	 */
	public String getYear() {
		return year;
	}

	/**
	 * @param year
	 *            the year to set
	 */
	public void setYear(String year) {
//		System.out.println(year+"=year");
		this.year = year;
	}

	/**
	 * @return the labor_capacity_added_value
	 */
	public double getLabor_capacity_added_value() {
		return labor_capacity_added_value;
	}

	/**
	 * @param labor_capacity_added_value
	 *            the labor_capacity_added_value to set
	 */
	public void setLabor_capacity_added_value(double labor_capacity_added_value) {
//		System.out.println(labor_capacity_added_value+"=labor_capacity_added_value");
		this.labor_capacity_added_value = labor_capacity_added_value;
	}

	/**
	 * @return the labor_capacity_productivity
	 */
	public double getLabor_capacity_productivity() {
		return labor_capacity_productivity;
	}

	/**
	 * @param labor_capacity_productivity
	 *            the labor_capacity_productivity to set
	 */
	public void setLabor_capacity_productivity(double labor_capacity_productivity) {
//		System.out.println(labor_capacity_productivity+"=labor_capacity_productivity");
		this.labor_capacity_productivity = labor_capacity_productivity;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		System.out.println("==================================================");
		super.setContentType(super.JSON);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("labor_capacity_year", year);
		map.put("labor_capacity_type", type);
		map.put("uid", userId);
		System.out.println(map);
		if (dataReportM_InnovateBaseDao.isEnterprise_Labor_CapacityExistBeforeInsert(map)) {
			super.outPrint("already");
			map.clear();
			return "json";
		}
		Enterprise_Labor_Capacity elc = new Enterprise_Labor_Capacity();
		elc.setEditable(1);
		elc.setEnterprise_id(dataReportM_InnovateBaseDao.getEnterpriseBaseId(userId));
		elc.setLabor_capacity_added_value(labor_capacity_added_value);
		elc.setLabor_capacity_check_pass(3);
		elc.setLabor_capacity_productivity(labor_capacity_productivity);
		elc.setLabor_capacity_staff_count(labor_capacity_staff_count);
		elc.setLabor_capacity_type(type);
		elc.setLabor_capacity_year(year);
		elc.setLabor_capacity_is_new(0);
		 if(dataReportM_InnovateBaseDao.insertNewEnterprise_Labor_Capacity(elc)){
			 super.outPrint("ok");
		 }else{
			 super.outPrint("fail");
		 }
		return "json";
	}

}
